#include<iostream>

using namespace std;
#define int long long

const int N = 1e6 + 10;
int n , m;
int h[N];
int check(int x)
{
    int ret = 0;
    for(int i = 1;i <= n;i ++)
    {
        if(h[i] > x) ret += h[i] - x;
    }
    return ret;
}
signed main()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i ++) cin >> h[i];
    int left = 0 , right = 2e9;
    while(left < right)
    {
        int mid = (left + right + 1) / 2;
        if(check(mid) >= m) left = mid;
        else right = mid - 1; 
    }
    cout << left << endl;
    return 0;
}